home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / PROGRAMM / PROGEDIT / 0748.ZIP / KEYTABLE.DOC < prev    next >
Text File  |  1987-01-15  |  8KB  |  192 lines

  1.                         REMAPPING THE KEYBOARD
  2.  
  3.     A character that you type at the keyboard can  take  on  256  dif-
  4. ferent values, ranging from 0 to 255. On the IBM PC, the ASCII charac-
  5. ters  are  numbered from 0 to 127, and the IBM extended characters are
  6. numbered from 128 to 255. All of the function key  combinations  (such
  7. as  F1  and  ALT  S) and numeric keypad combinations (such as PGDN and
  8. INS) fall into the extended character set. 
  9.  
  10.     The  editor  has  an internal table which is used to translate one
  11. keystroke value into another. This internal table is 256  bytes  long,
  12. with  byte 0 holding the translation value for keystroke value 0, byte
  13. 1 holding the value for keystroke 1, etc. The default values for  this
  14. table  indicate  no  translations (ie keystroke number n is translated
  15. into value n.) 
  16.  
  17.     This internal table can  be  altered  by  the  user  by  making  a
  18. KEYTABLE.ME  file.  This file is a mirror image of the internal table,
  19. with certain values altered. You need to create a file which tells the
  20. keystroke compiler which values in the KEYTABLE.ME file to change.
  21.  
  22.  
  23.                        AN EXAMPLE OF REMAPPING
  24.  
  25.     As an example where translation may be desirable, let's consider a
  26. very  simple remapping of the keyboard. Right now, the command that is
  27. associated with the F1 function key is <DELETE LINE> and  the  command
  28. that's associated with the <ALT> H key is <HELP>. Let's say  that  you
  29. would  like  the <HELP> function to be assigned to the F1 key, and the
  30. <DELETE LINE> function assigned to the <ALT> D key. 
  31.  
  32.     To  find  out  what  keystroke  values the F1, <ALT> D and <ALT> H
  33. keys   produce,   use   the  <TEST  KEYS>  command  from  the  editor.
  34. This command is done by pressing the <ALT> F10 key.  The  <TEST  KEYS>
  35. command  prompts  you  for a keystroke, and then prints the value that
  36. the keystroke produced. (You hit the  <ESC>  key  to  exit  from  this
  37. command.)
  38.  
  39.     After invoking the <TEST KEYS> command, we find that the following
  40. values are produced :
  41.  
  42.   F1     187
  43.   ALT D  160
  44.   ALT H  163
  45.  
  46.     What we would like to do is have the F1 key "generate" the <ALT> H
  47. keystroke,  and have the <ALT> D key "generate" the F1 value. In other
  48. words, we would like to fool the editor into thinking that when the F1
  49. key is pressed, the <ALT> H key was really pressed.
  50.  
  51.     To effect these changes, we would like to put the value  163  into
  52. byte  187  of the table, and put value 187 into byte 160 of the table.
  53. How can we do this without  going  altering  the  editor's  executable
  54. file?
  55.  
  56.  
  57.                           THE KEYTABLE FILE
  58.  
  59.     The  file  which  holds the keystroke translation values is called
  60. "KEYTABLE.ME".  When  the editor starts up, it will first look in your
  61. current subdirectory for the KEYTABLE.ME file. If the  editor  doesn't
  62. find  it  there, then the editor will search the directories listed in
  63. your ME environment variable, and then in your  DOS  search  path.  If
  64. this file still isn't found, then the internal table is filled sequen-
  65. tially  with  the  values  0 through 255. This means that no remapping
  66. will be performed. 
  67.  
  68.     The KEYTABLE.ME file contains one or more tables  which  are  256
  69. bytes long, with byte i corresponding to keystroke i. The editor comes
  70. with a default KEYTABLE.ME file. It also comes with several  utilities
  71. to create and alter the KEYTABLE.ME file. 
  72.  
  73.     The  first  utility we will talk about is called KEYCOMP.EXE. This
  74. program  reads  a  keystroke  configuration  file  and   generates   a
  75. KEYTABLE.ME file  from  it. A keystroke configuration file contains a
  76. list of keystrokes and their corresponding values. 
  77.  
  78.     Each line of the keystroke configuration file has the form :
  79.  
  80.   key=func
  81.  
  82.     The  "key"  can  be  a  decimal number, a single character between
  83. single quotes, ^char (a control character between 0 and 31), F#  where
  84. '#'  is a number between 1 and 10 (this is a normal function key), AF#
  85. (ALT function key), SF# (SHIFT function key), CF# (CTRL function key),
  86. or @char (ALT character key).
  87.  
  88.     "Func" is a number representing the value that the key produces.
  89.  
  90.     Here are some examples :
  91.  
  92.   120=122   (the key with the value 120 produces 122)
  93.   '#'=289   (a pound sign produces 289)
  94.   ^C=14     (CTRL C produces 14)
  95.   F1=160    (F1 produces 160)
  96.   @A=198    (ALT A produces 198)
  97.   SF9=130   (SHIFT f9 produces 130)
  98.  
  99.     Any keystrokes which aren't mentioned in  the  configuration  file
  100. will just be translated into themselves.
  101.  
  102.     To run the keystroke compiler, type the command
  103.  
  104.     KEYCOMP filename
  105.  
  106. where filename is the name of the  keystroke  configuration  file.  If
  107. everything  goes  well, the KEYTABLE.ME file will be created. You can
  108. not TYPE out the KEYTABLE.ME file  since  it  contains  binary  data.
  109. However,  you  can examine it with various disk utilities (such as the
  110. NORTON Utilities). 
  111.  
  112.     The second utility is called KEYCONF.EXE. This program generates a
  113. default keystroke configuration file.  There  are  256  lines  in  the
  114. generated file. The file looks like this : 
  115.  
  116. 0=0
  117. 1=1
  118. ...
  119. 255=255
  120.  
  121.     The  output  from  this  program is written to the screen. You can
  122. redirect the output to a file be giving the command :
  123.     
  124.     KEYCONF > keyfile (or any other name)
  125.  
  126.     Once  this  sample  keystroke configuration file is generated, you
  127. can alter  it  with  any  text  editor,  and  then  compile  it  using
  128. KEYCOMP.EXE. 
  129.  
  130.     The third utility is called KEYTEST.EXE. This  program  waits  for
  131. you  to  type  a  keystroke,  and  then  prints  out the value of that
  132. keystroke. Hitting the <ESC> key will stop the program.  This  program
  133. is also simulated by the <TEST KEYS> command of the editor. 
  134.  
  135.  
  136.     Returning  to  the  problem  mentioned  at  the  beginning of this
  137. section, we want to have the F1 key generate 163 and we want the <ALT>
  138. D key generate 187.  We  use  the  editor  to  create  a  file  called
  139. "NEWKEYS" which has the lines
  140.   @D=F1
  141.   F1=@H
  142. We   then  use  the  command  "KEYCOMP  NEWKEYS"  to  create  the  new
  143. KEYTABLE.ME file. Now, when the editor starts up,  the  new  keystroke
  144. mapping will be in effect.
  145.  
  146.  
  147.                                PREFIXES
  148.  
  149.     Some  people  would like to have the editor emulate their favorite
  150. word processor, and hence, will make key maps which map  the  function
  151. keys  of  the  editor  into  the  keystrokes that their word processor
  152. requires.  Some  word  processors  use  a  two-keystroke  sequence  to
  153. generate  a  command.  One  of the most well-known examples of this is
  154. WordStar (WordStar is a trademark of MicroPro Inc.). For instance, the
  155. keystroke sequence CTRL K D is used to exit WordStar.
  156.  
  157.     You can specify prefixes in the keystroke redefinition file  which
  158. is compiled by the KEYCOMP.EXE program. A prefix line is of the form :
  159.  
  160.   PREFIX <keystroke>
  161.  
  162.     The  PREFIX  statement creates a 256 byte table which contains the
  163. commands generated by the second key of the sequence. As  an  example,
  164. you  press  CTRL  D  right  now to exit the editor. CTRL D generates a
  165. keystroke value of 4. If you would like to use the CTRL K D  keystroke
  166. combination  to  exit  the  editor  instead,  then your keystroke file
  167. should contain a line like this :
  168.  
  169.   PREFIX ^K
  170.   .....        list of CTRL K commands
  171.   D=4
  172.   ......
  173.  
  174.  
  175.     A prefix command table ends when the compiler  encounters  another
  176. PREFIX  statement,  or  when  the  compiler  reaches  the  end  of the
  177. redefinition file. 
  178.  
  179.     All of the prefix definitions should come  after  the  definitions
  180. for  the main table. For a good example, examine the WSKEYS file which
  181. comes with the keyboard remapping facility.  This  file  contains  the
  182. keystroke definitions to configure the keyboard like WordStar.
  183.  
  184.  
  185.                              SOURCE FILES
  186.  
  187.     Included  in  the editor package are the source files to the above
  188. mentioned utilities. We request that if you improve  these  utilities,
  189. that  you  send the source back to us so that we can incorporate it in
  190. future releases. In exchange, you will receive a free copy of the next
  191. release of the editor.
  192.